﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
/* This Model handles every information related to the user starting from his password and username and email 
 * and date of birth and picture!
 * Each class contains create and modified times for security reasons
 */
namespace Fish.Models
{
    public class Users
    {
        public int ID { get; set; }
        
        [Required]
        [StringLength(50,MinimumLength=5)]
        public string Username { get; set; }

        [Required]
        [StringLength(50, MinimumLength = 5,ErrorMessage="Password must be more than 5")]
        [DataType(DataType.Password)]
        public string Password { get; set; }
    
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
        public DateTime? DateOfBirth { get; set; }
        
        [Required]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }

        [DataType(DataType.DateTime)]
        [ScaffoldColumn(false)]
        public DateTime Created { get; set; }
        
        [DataType(DataType.DateTime)]
        [ScaffoldColumn(false)]
        public DateTime Modified { get; set; }

        [DataType(DataType.Text)]
        [ScaffoldColumn(false)]
        public string Salt { get; set; }

        public byte[] UserImage { get; set; }

        public virtual ICollection<EventUserRelations> EventUserRelations { get; set; }
        public virtual ICollection<Templates> Templates { get; set; }

        public Users()
        {
            this.Created = DateTime.Now;
            this.Modified = DateTime.Now;
        }

        public Users(string username, string password, string email, DateTime dob)
        {
            this.Username = username;
            this.Password = password;
            this.Email = email;
            this.DateOfBirth = dob;
            this.Created = DateTime.Now;
            this.Modified = DateTime.Now;
        }

    }
}